package com.ourteam.scm.utils;

import java.io.File;

import org.apache.commons.io.filefilter.IOFileFilter;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.ISVNInfo;

public class NotInSVNFileFilter implements IOFileFilter {

	private ISVNClientAdapter clientAdapter;

	public NotInSVNFileFilter(ISVNClientAdapter clientAdapter) {
		super();
		this.clientAdapter = clientAdapter;
	}

	@Override
	public boolean accept(File arg0, String arg1) {
		return accept(new File(arg0, arg1));
	}

	@Override
	public boolean accept(File arg0) {
		if (arg0.isHidden()) {
			return false;
		}

		try {

			ISVNInfo info = clientAdapter.getInfo(arg0);
			
			if(info == null || info.getRevision() == null) {
				return true;
			}
			else {
				return false;
			}

		} catch (Exception e) {
			
			return true;
		}

	}
}